package com.ruicar.afs.cloud.risk.tortoise.controller;

import com.ruicar.afs.cloud.common.core.util.IResponse;
import com.ruicar.afs.cloud.risk.api.dto.tortoise.TortoiseResultNotice;
import com.ruicar.afs.cloud.risk.api.dto.tortoise.TortoiseQueryBean;
import com.ruicar.afs.cloud.risk.api.dto.tortoise.request.TortoiseFraudPushData;
import com.ruicar.afs.cloud.risk.api.dto.tortoise.request.TortoiseApplyData;
import com.ruicar.afs.cloud.risk.api.dto.tortoise.request.TortoisePrevApproveData;
import com.ruicar.afs.cloud.risk.tortoise.processor.AfsTortoiseProcessor;
import com.ruicar.afs.cloud.risk.tortoise.service.AfsCreditTortoiseRecordService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Description 业务端玄武调用
 * @Author Peng Jinbo
 * @Date 2020/07/24 11:35
 */
@RestController
@Slf4j
@AllArgsConstructor
@RequestMapping("/afs/tortoise")
public class AfsTortoiseController {

    /**
     * Afs tortoise processor
     */
    private AfsTortoiseProcessor afsTortoiseProcessor;

    /**
     * Afs credit tortoise record service
     */
    private AfsCreditTortoiseRecordService afsCreditTortoiseRecordService;

    /**
     * Author Peng Jinbo
     * Signal response
     *
     * @param reqData req data
     * @return the response
     */
    @PostMapping("/signalApply")
    public IResponse signalApply(@RequestBody TortoiseApplyData reqData){
        log.info("正式进件调用：{}",reqData);
        return afsTortoiseProcessor.signal(reqData);
    }


    @PostMapping("/signalFraudHand")
    public IResponse signalFraudHand(@RequestBody TortoiseApplyData reqData){
        log.info("反欺诈手工触发：{}",reqData);
        return afsTortoiseProcessor.signal(reqData);
    }

    @PostMapping("/signalDecisionHand")
    public IResponse signalDecisionHand(@RequestBody TortoiseApplyData reqData){
        log.info("决策引擎手工调用：{}",reqData);
        return afsTortoiseProcessor.signal(reqData);
    }

    @PostMapping("/signalPrevApprove")
    public IResponse signalPrevApprove(@RequestBody TortoisePrevApproveData reqData){
        log.info("预审批：{}",reqData);
        return afsTortoiseProcessor.signal(reqData);
    }

    @PostMapping("/signalFraudPush")
    public IResponse signalFraudPush(@RequestBody TortoiseFraudPushData reqData){
        log.info("欺诈信息上送：{}",reqData);
        return afsTortoiseProcessor.signal(reqData);
    }


    /**
     * Author Peng Jinbo
     * Query record response
     *
     * @param queryBean query bean
     * @return the response
     */
    @PostMapping("/noticeResult")
    public IResponse<TortoiseResultNotice> queryNotice(@RequestBody TortoiseQueryBean queryBean){
        return IResponse.success(afsCreditTortoiseRecordService.getNotice(queryBean.getSerialNumber()));
    }

}
